.class public Lnet/oauth/signature/RSA_SHA1;
.super Lnet/oauth/signature/OAuthSignatureMethod;
.source "RSA_SHA1.java"


# static fields
.field public static final PRIVATE_KEY:Ljava/lang/String; = "RSA-SHA1.PrivateKey"

.field public static final PUBLIC_KEY:Ljava/lang/String; = "RSA-SHA1.PublicKey"

.field public static final X509_CERTIFICATE:Ljava/lang/String; = "RSA-SHA1.X509Certificate"


# instance fields
.field private privateKey:Ljava/security/PrivateKey;

.field private publicKey:Ljava/security/PublicKey;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 86
    invoke-direct {p0}, Lnet/oauth/signature/OAuthSignatureMethod;-><init>()V

    .line 92
    iput-object v0, p0, Lnet/oauth/signature/RSA_SHA1;->privateKey:Ljava/security/PrivateKey;

    .line 93
    iput-object v0, p0, Lnet/oauth/signature/RSA_SHA1;->publicKey:Ljava/security/PublicKey;

    return-void
.end method

.method private getPrivateKeyFromDer([B)Ljava/security/PrivateKey;
    .locals 3
    .parameter "privateKeyObject"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 165
    const-string v2, "RSA"

    invoke-static {v2}, Ljava/security/KeyFactory;->getInstance(Ljava/lang/String;)Ljava/security/KeyFactory;

    move-result-object v0

    .line 166
    .local v0, fac:Ljava/security/KeyFactory;
    new-instance v1, Ljava/security/spec/PKCS8EncodedKeySpec;

    invoke-direct {v1, p1}, Ljava/security/spec/PKCS8EncodedKeySpec;-><init>([B)V

    .line 167
    .local v1, privKeySpec:Ljava/security/spec/EncodedKeySpec;
    invoke-virtual {v0, v1}, Ljava/security/KeyFactory;->generatePrivate(Ljava/security/spec/KeySpec;)Ljava/security/PrivateKey;

    move-result-object v2

    return-object v2
.end method

.method private getPrivateKeyFromPem(Ljava/lang/String;)Ljava/security/PrivateKey;
    .locals 8
    .parameter "pem"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;,
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 173
    new-instance v4, Ljava/io/ByteArrayInputStream;

    const-string v5, "UTF-8"

    invoke-virtual {p1, v5}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/io/ByteArrayInputStream;-><init>([B)V

    .line 176
    .local v4, stream:Ljava/io/InputStream;
    new-instance v3, Lnet/oauth/signature/pem/PEMReader;

    invoke-direct {v3, v4}, Lnet/oauth/signature/pem/PEMReader;-><init>(Ljava/io/InputStream;)V

    .line 177
    .local v3, reader:Lnet/oauth/signature/pem/PEMReader;
    invoke-virtual {v3}, Lnet/oauth/signature/pem/PEMReader;->getDerBytes()[B

    move-result-object v0

    .line 180
    .local v0, bytes:[B
    const-string v5, "-----BEGIN RSA PRIVATE KEY-----"

    invoke-virtual {v3}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 181
    new-instance v5, Lnet/oauth/signature/pem/PKCS1EncodedKeySpec;

    invoke-direct {v5, v0}, Lnet/oauth/signature/pem/PKCS1EncodedKeySpec;-><init>([B)V

    invoke-virtual {v5}, Lnet/oauth/signature/pem/PKCS1EncodedKeySpec;->getKeySpec()Ljava/security/spec/RSAPrivateCrtKeySpec;

    move-result-object v2

    .line 189
    .local v2, keySpec:Ljava/security/spec/KeySpec;
    :goto_0
    const-string v5, "RSA"

    invoke-static {v5}, Ljava/security/KeyFactory;->getInstance(Ljava/lang/String;)Ljava/security/KeyFactory;

    move-result-object v1

    .line 190
    .local v1, fac:Ljava/security/KeyFactory;
    invoke-virtual {v1, v2}, Ljava/security/KeyFactory;->generatePrivate(Ljava/security/spec/KeySpec;)Ljava/security/PrivateKey;

    move-result-object v5

    return-object v5

    .line 182
    .end local v1           #fac:Ljava/security/KeyFactory;
    .end local v2           #keySpec:Ljava/security/spec/KeySpec;
    :cond_0
    const-string v5, "-----BEGIN PRIVATE KEY-----"

    invoke-virtual {v3}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 183
    new-instance v2, Ljava/security/spec/PKCS8EncodedKeySpec;

    invoke-direct {v2, v0}, Ljava/security/spec/PKCS8EncodedKeySpec;-><init>([B)V

    .restart local v2       #keySpec:Ljava/security/spec/KeySpec;
    goto :goto_0

    .line 185
    .end local v2           #keySpec:Ljava/security/spec/KeySpec;
    :cond_1
    new-instance v5, Ljava/io/IOException;

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    const-string v7, "Invalid PEM file: Unknown marker for private key "

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v3}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v5
.end method

.method private getPublicKeyFromDer([B)Ljava/security/PublicKey;
    .locals 3
    .parameter "publicKeyObject"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 134
    const-string v2, "RSA"

    invoke-static {v2}, Ljava/security/KeyFactory;->getInstance(Ljava/lang/String;)Ljava/security/KeyFactory;

    move-result-object v0

    .line 135
    .local v0, fac:Ljava/security/KeyFactory;
    new-instance v1, Ljava/security/spec/X509EncodedKeySpec;

    invoke-direct {v1, p1}, Ljava/security/spec/X509EncodedKeySpec;-><init>([B)V

    .line 136
    .local v1, pubKeySpec:Ljava/security/spec/EncodedKeySpec;
    invoke-virtual {v0, v1}, Ljava/security/KeyFactory;->generatePublic(Ljava/security/spec/KeySpec;)Ljava/security/PublicKey;

    move-result-object v2

    return-object v2
.end method

.method private getPublicKeyFromDerCert([B)Ljava/security/PublicKey;
    .locals 4
    .parameter "certObject"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 126
    const-string v3, "X509"

    invoke-static {v3}, Ljava/security/cert/CertificateFactory;->getInstance(Ljava/lang/String;)Ljava/security/cert/CertificateFactory;

    move-result-object v1

    .line 127
    .local v1, fac:Ljava/security/cert/CertificateFactory;
    new-instance v2, Ljava/io/ByteArrayInputStream;

    invoke-direct {v2, p1}, Ljava/io/ByteArrayInputStream;-><init>([B)V

    .line 128
    .local v2, in:Ljava/io/ByteArrayInputStream;
    invoke-virtual {v1, v2}, Ljava/security/cert/CertificateFactory;->generateCertificate(Ljava/io/InputStream;)Ljava/security/cert/Certificate;

    move-result-object v0

    check-cast v0, Ljava/security/cert/X509Certificate;

    .line 129
    .local v0, cert:Ljava/security/cert/X509Certificate;
    invoke-virtual {v0}, Ljava/security/cert/X509Certificate;->getPublicKey()Ljava/security/PublicKey;

    move-result-object v3

    return-object v3
.end method

.method private getPublicKeyFromPem(Ljava/lang/String;)Ljava/security/PublicKey;
    .locals 9
    .parameter "pem"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;,
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 142
    new-instance v5, Ljava/io/ByteArrayInputStream;

    const-string v6, "UTF-8"

    invoke-virtual {p1, v6}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/io/ByteArrayInputStream;-><init>([B)V

    .line 145
    .local v5, stream:Ljava/io/InputStream;
    new-instance v4, Lnet/oauth/signature/pem/PEMReader;

    invoke-direct {v4, v5}, Lnet/oauth/signature/pem/PEMReader;-><init>(Ljava/io/InputStream;)V

    .line 146
    .local v4, reader:Lnet/oauth/signature/pem/PEMReader;
    invoke-virtual {v4}, Lnet/oauth/signature/pem/PEMReader;->getDerBytes()[B

    move-result-object v0

    .line 149
    .local v0, bytes:[B
    const-string v6, "-----BEGIN PUBLIC KEY-----"

    invoke-virtual {v4}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v6

    if-eqz v6, :cond_0

    .line 150
    new-instance v2, Ljava/security/spec/X509EncodedKeySpec;

    invoke-direct {v2, v0}, Ljava/security/spec/X509EncodedKeySpec;-><init>([B)V

    .line 151
    .local v2, keySpec:Ljava/security/spec/KeySpec;
    const-string v6, "RSA"

    invoke-static {v6}, Ljava/security/KeyFactory;->getInstance(Ljava/lang/String;)Ljava/security/KeyFactory;

    move-result-object v1

    .line 152
    .local v1, fac:Ljava/security/KeyFactory;
    invoke-virtual {v1, v2}, Ljava/security/KeyFactory;->generatePublic(Ljava/security/spec/KeySpec;)Ljava/security/PublicKey;

    move-result-object v3

    .line 160
    .end local v1           #fac:Ljava/security/KeyFactory;
    .end local v2           #keySpec:Ljava/security/spec/KeySpec;
    .local v3, pubKey:Ljava/security/PublicKey;
    :goto_0
    return-object v3

    .line 153
    .end local v3           #pubKey:Ljava/security/PublicKey;
    :cond_0
    const-string v6, "-----BEGIN CERTIFICATE-----"

    invoke-virtual {v4}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v6

    if-eqz v6, :cond_1

    .line 154
    invoke-direct {p0, v0}, Lnet/oauth/signature/RSA_SHA1;->getPublicKeyFromDerCert([B)Ljava/security/PublicKey;

    move-result-object v3

    .restart local v3       #pubKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 156
    .end local v3           #pubKey:Ljava/security/PublicKey;
    :cond_1
    new-instance v6, Ljava/io/IOException;

    new-instance v7, Ljava/lang/StringBuilder;

    invoke-direct {v7}, Ljava/lang/StringBuilder;-><init>()V

    const-string v8, "Invalid PEM fileL: Unknown marker for  public key or cert "

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v4}, Lnet/oauth/signature/pem/PEMReader;->getBeginMarker()Ljava/lang/String;

    move-result-object v8

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    invoke-direct {v6, v7}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    throw v6
.end method

.method private loadPrivateKey(Ljava/lang/Object;)Ljava/security/PrivateKey;
    .locals 6
    .parameter "privateKeyObject"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 260
    instance-of v3, p1, Ljava/security/PrivateKey;

    if-eqz v3, :cond_0

    move-object v2, p1

    .line 261
    check-cast v2, Ljava/security/PrivateKey;

    .line 280
    .end local p1
    .local v2, privateKey:Ljava/security/PrivateKey;
    :goto_0
    return-object v2

    .line 262
    .end local v2           #privateKey:Ljava/security/PrivateKey;
    .restart local p1
    :cond_0
    instance-of v3, p1, Ljava/lang/String;

    if-eqz v3, :cond_1

    .line 265
    :try_start_0
    move-object v0, p1

    check-cast v0, Ljava/lang/String;

    move-object v3, v0

    invoke-direct {p0, v3}, Lnet/oauth/signature/RSA_SHA1;->getPrivateKeyFromPem(Ljava/lang/String;)Ljava/security/PrivateKey;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .restart local v2       #privateKey:Ljava/security/PrivateKey;
    goto :goto_0

    .line 266
    .end local v2           #privateKey:Ljava/security/PrivateKey;
    :catch_0
    move-exception v1

    .line 268
    .local v1, e:Ljava/io/IOException;
    check-cast p1, Ljava/lang/String;

    .end local p1
    invoke-static {p1}, Lnet/oauth/signature/RSA_SHA1;->decodeBase64(Ljava/lang/String;)[B

    move-result-object v3

    invoke-direct {p0, v3}, Lnet/oauth/signature/RSA_SHA1;->getPrivateKeyFromDer([B)Ljava/security/PrivateKey;

    move-result-object v2

    .line 270
    .restart local v2       #privateKey:Ljava/security/PrivateKey;
    goto :goto_0

    .line 271
    .end local v1           #e:Ljava/io/IOException;
    .end local v2           #privateKey:Ljava/security/PrivateKey;
    .restart local p1
    :cond_1
    instance-of v3, p1, [B

    if-eqz v3, :cond_2

    .line 272
    check-cast p1, [B

    .end local p1
    check-cast p1, [B

    invoke-direct {p0, p1}, Lnet/oauth/signature/RSA_SHA1;->getPrivateKeyFromDer([B)Ljava/security/PrivateKey;

    move-result-object v2

    .restart local v2       #privateKey:Ljava/security/PrivateKey;
    goto :goto_0

    .line 274
    .end local v2           #privateKey:Ljava/security/PrivateKey;
    .restart local p1
    :cond_2
    new-instance v3, Ljava/lang/IllegalArgumentException;

    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "Private key set through RSA_SHA1.PRIVATE_KEY must be of type PrivateKey, String or byte[] and not "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    invoke-direct {v3, v4}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v3
.end method

.method private loadPublicKey(Ljava/lang/Object;Z)Ljava/security/PublicKey;
    .locals 7
    .parameter "publicKeyObject"
    .parameter "isCert"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 304
    instance-of v4, p1, Ljava/security/PublicKey;

    if-eqz v4, :cond_0

    move-object v2, p1

    .line 305
    check-cast v2, Ljava/security/PublicKey;

    .line 335
    .end local p1
    .local v2, publicKey:Ljava/security/PublicKey;
    :goto_0
    return-object v2

    .line 306
    .end local v2           #publicKey:Ljava/security/PublicKey;
    .restart local p1
    :cond_0
    instance-of v4, p1, Ljava/security/cert/X509Certificate;

    if-eqz v4, :cond_1

    .line 307
    check-cast p1, Ljava/security/cert/X509Certificate;

    .end local p1
    invoke-virtual {p1}, Ljava/security/cert/X509Certificate;->getPublicKey()Ljava/security/PublicKey;

    move-result-object v2

    .restart local v2       #publicKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 308
    .end local v2           #publicKey:Ljava/security/PublicKey;
    .restart local p1
    :cond_1
    instance-of v4, p1, Ljava/lang/String;

    if-eqz v4, :cond_3

    .line 310
    :try_start_0
    move-object v0, p1

    check-cast v0, Ljava/lang/String;

    move-object v4, v0

    invoke-direct {p0, v4}, Lnet/oauth/signature/RSA_SHA1;->getPublicKeyFromPem(Ljava/lang/String;)Ljava/security/PublicKey;
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .restart local v2       #publicKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 311
    .end local v2           #publicKey:Ljava/security/PublicKey;
    :catch_0
    move-exception v1

    .line 313
    .local v1, e:Ljava/io/IOException;
    if-eqz p2, :cond_2

    .line 314
    throw v1

    .line 315
    :cond_2
    check-cast p1, Ljava/lang/String;

    .end local p1
    invoke-static {p1}, Lnet/oauth/signature/RSA_SHA1;->decodeBase64(Ljava/lang/String;)[B

    move-result-object v4

    invoke-direct {p0, v4}, Lnet/oauth/signature/RSA_SHA1;->getPublicKeyFromDer([B)Ljava/security/PublicKey;

    move-result-object v2

    .line 317
    .restart local v2       #publicKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 318
    .end local v1           #e:Ljava/io/IOException;
    .end local v2           #publicKey:Ljava/security/PublicKey;
    .restart local p1
    :cond_3
    instance-of v4, p1, [B

    if-eqz v4, :cond_5

    .line 319
    if-eqz p2, :cond_4

    .line 320
    check-cast p1, [B

    .end local p1
    check-cast p1, [B

    invoke-direct {p0, p1}, Lnet/oauth/signature/RSA_SHA1;->getPublicKeyFromDerCert([B)Ljava/security/PublicKey;

    move-result-object v2

    .restart local v2       #publicKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 322
    .end local v2           #publicKey:Ljava/security/PublicKey;
    .restart local p1
    :cond_4
    check-cast p1, [B

    .end local p1
    check-cast p1, [B

    invoke-direct {p0, p1}, Lnet/oauth/signature/RSA_SHA1;->getPublicKeyFromDer([B)Ljava/security/PublicKey;

    move-result-object v2

    .restart local v2       #publicKey:Ljava/security/PublicKey;
    goto :goto_0

    .line 325
    .end local v2           #publicKey:Ljava/security/PublicKey;
    .restart local p1
    :cond_5
    if-eqz p2, :cond_6

    .line 326
    const-string v3, "RSA_SHA1.X509_CERTIFICATE"

    .line 329
    .local v3, source:Ljava/lang/String;
    :goto_1
    new-instance v4, Ljava/lang/IllegalArgumentException;

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    const-string v6, "Public key or certificate set through "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " must be of "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "type PublicKey, String or byte[], and not "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v4

    .line 328
    .end local v3           #source:Ljava/lang/String;
    :cond_6
    const-string v3, "RSA_SHA1.PUBLIC_KEY"

    .restart local v3       #source:Ljava/lang/String;
    goto :goto_1
.end method

.method private sign([B)[B
    .locals 3
    .parameter "message"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 219
    iget-object v1, p0, Lnet/oauth/signature/RSA_SHA1;->privateKey:Ljava/security/PrivateKey;

    if-nez v1, :cond_0

    .line 220
    new-instance v1, Ljava/lang/IllegalStateException;

    const-string v2, "need to set private key with OAuthConsumer.setProperty when generating RSA-SHA1 signatures."

    invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 224
    :cond_0
    const-string v1, "SHA1withRSA"

    invoke-static {v1}, Ljava/security/Signature;->getInstance(Ljava/lang/String;)Ljava/security/Signature;

    move-result-object v0

    .line 225
    .local v0, signer:Ljava/security/Signature;
    iget-object v1, p0, Lnet/oauth/signature/RSA_SHA1;->privateKey:Ljava/security/PrivateKey;

    invoke-virtual {v0, v1}, Ljava/security/Signature;->initSign(Ljava/security/PrivateKey;)V

    .line 226
    invoke-virtual {v0, p1}, Ljava/security/Signature;->update([B)V

    .line 227
    invoke-virtual {v0}, Ljava/security/Signature;->sign()[B

    move-result-object v1

    return-object v1
.end method

.method private verify([B[B)Z
    .locals 3
    .parameter "signature"
    .parameter "message"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/security/GeneralSecurityException;
        }
    .end annotation

    .prologue
    .line 232
    iget-object v1, p0, Lnet/oauth/signature/RSA_SHA1;->publicKey:Ljava/security/PublicKey;

    if-nez v1, :cond_0

    .line 233
    new-instance v1, Ljava/lang/IllegalStateException;

    const-string v2, "need to set public key with  OAuthConsumer.setProperty when verifying RSA-SHA1 signatures."

    invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v1

    .line 237
    :cond_0
    const-string v1, "SHA1withRSA"

    invoke-static {v1}, Ljava/security/Signature;->getInstance(Ljava/lang/String;)Ljava/security/Signature;

    move-result-object v0

    .line 238
    .local v0, verifier:Ljava/security/Signature;
    iget-object v1, p0, Lnet/oauth/signature/RSA_SHA1;->publicKey:Ljava/security/PublicKey;

    invoke-virtual {v0, v1}, Ljava/security/Signature;->initVerify(Ljava/security/PublicKey;)V

    .line 239
    invoke-virtual {v0, p2}, Ljava/security/Signature;->update([B)V

    .line 240
    invoke-virtual {v0, p1}, Ljava/security/Signature;->verify([B)Z

    move-result v1

    return v1
.end method


# virtual methods
.method protected getSignature(Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .parameter "baseString"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lnet/oauth/OAuthException;
        }
    .end annotation

    .prologue
    .line 196
    :try_start_0
    const-string v2, "UTF-8"

    invoke-virtual {p1, v2}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v2

    invoke-direct {p0, v2}, Lnet/oauth/signature/RSA_SHA1;->sign([B)[B

    move-result-object v1

    .line 197
    .local v1, signature:[B
    invoke-static {v1}, Lnet/oauth/signature/RSA_SHA1;->base64Encode([B)Ljava/lang/String;
    :try_end_0
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_0} :catch_1

    move-result-object v2

    return-object v2

    .line 198
    .end local v1           #signature:[B
    :catch_0
    move-exception v0

    .line 199
    .local v0, e:Ljava/io/UnsupportedEncodingException;
    new-instance v2, Lnet/oauth/OAuthException;

    invoke-direct {v2, v0}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v2

    .line 200
    .end local v0           #e:Ljava/io/UnsupportedEncodingException;
    :catch_1
    move-exception v0

    .line 201
    .local v0, e:Ljava/security/GeneralSecurityException;
    new-instance v2, Lnet/oauth/OAuthException;

    invoke-direct {v2, v0}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v2
.end method

.method protected initialize(Ljava/lang/String;Lnet/oauth/OAuthAccessor;)V
    .locals 6
    .parameter "name"
    .parameter "accessor"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lnet/oauth/OAuthException;
        }
    .end annotation

    .prologue
    .line 98
    invoke-super {p0, p1, p2}, Lnet/oauth/signature/OAuthSignatureMethod;->initialize(Ljava/lang/String;Lnet/oauth/OAuthAccessor;)V

    .line 103
    :try_start_0
    iget-object v4, p2, Lnet/oauth/OAuthAccessor;->consumer:Lnet/oauth/OAuthConsumer;

    const-string v5, "RSA-SHA1.PrivateKey"

    invoke-virtual {v4, v5}, Lnet/oauth/OAuthConsumer;->getProperty(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    .line 104
    .local v2, privateKeyObject:Ljava/lang/Object;
    if-eqz v2, :cond_0

    .line 105
    invoke-direct {p0, v2}, Lnet/oauth/signature/RSA_SHA1;->loadPrivateKey(Ljava/lang/Object;)Ljava/security/PrivateKey;

    move-result-object v4

    iput-object v4, p0, Lnet/oauth/signature/RSA_SHA1;->privateKey:Ljava/security/PrivateKey;

    .line 108
    :cond_0
    iget-object v4, p2, Lnet/oauth/OAuthAccessor;->consumer:Lnet/oauth/OAuthConsumer;

    const-string v5, "RSA-SHA1.PublicKey"

    invoke-virtual {v4, v5}, Lnet/oauth/OAuthConsumer;->getProperty(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v3

    .line 109
    .local v3, publicKeyObject:Ljava/lang/Object;
    if-eqz v3, :cond_2

    .line 110
    const/4 v4, 0x0

    invoke-direct {p0, v3, v4}, Lnet/oauth/signature/RSA_SHA1;->loadPublicKey(Ljava/lang/Object;Z)Ljava/security/PublicKey;

    move-result-object v4

    iput-object v4, p0, Lnet/oauth/signature/RSA_SHA1;->publicKey:Ljava/security/PublicKey;

    .line 122
    :cond_1
    :goto_0
    return-void

    .line 112
    :cond_2
    iget-object v4, p2, Lnet/oauth/OAuthAccessor;->consumer:Lnet/oauth/OAuthConsumer;

    const-string v5, "RSA-SHA1.X509Certificate"

    invoke-virtual {v4, v5}, Lnet/oauth/OAuthConsumer;->getProperty(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    .line 113
    .local v0, certObject:Ljava/lang/Object;
    if-eqz v0, :cond_1

    .line 114
    const/4 v4, 0x1

    invoke-direct {p0, v0, v4}, Lnet/oauth/signature/RSA_SHA1;->loadPublicKey(Ljava/lang/Object;Z)Ljava/security/PublicKey;

    move-result-object v4

    iput-object v4, p0, Lnet/oauth/signature/RSA_SHA1;->publicKey:Ljava/security/PublicKey;
    :try_end_0
    .catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    goto :goto_0

    .line 117
    .end local v0           #certObject:Ljava/lang/Object;
    .end local v2           #privateKeyObject:Ljava/lang/Object;
    .end local v3           #publicKeyObject:Ljava/lang/Object;
    :catch_0
    move-exception v1

    .line 118
    .local v1, e:Ljava/security/GeneralSecurityException;
    new-instance v4, Lnet/oauth/OAuthException;

    invoke-direct {v4, v1}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v4

    .line 119
    .end local v1           #e:Ljava/security/GeneralSecurityException;
    :catch_1
    move-exception v1

    .line 120
    .local v1, e:Ljava/io/IOException;
    new-instance v4, Lnet/oauth/OAuthException;

    invoke-direct {v4, v1}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v4
.end method

.method protected isValid(Ljava/lang/String;Ljava/lang/String;)Z
    .locals 3
    .parameter "signature"
    .parameter "baseString"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lnet/oauth/OAuthException;
        }
    .end annotation

    .prologue
    .line 209
    :try_start_0
    invoke-static {p1}, Lnet/oauth/signature/RSA_SHA1;->decodeBase64(Ljava/lang/String;)[B

    move-result-object v1

    const-string v2, "UTF-8"

    invoke-virtual {p2, v2}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v2

    invoke-direct {p0, v1, v2}, Lnet/oauth/signature/RSA_SHA1;->verify([B[B)Z
    :try_end_0
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_0} :catch_1

    move-result v1

    return v1

    .line 211
    :catch_0
    move-exception v0

    .line 212
    .local v0, e:Ljava/io/UnsupportedEncodingException;
    new-instance v1, Lnet/oauth/OAuthException;

    invoke-direct {v1, v0}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v1

    .line 213
    .end local v0           #e:Ljava/io/UnsupportedEncodingException;
    :catch_1
    move-exception v0

    .line 214
    .local v0, e:Ljava/security/GeneralSecurityException;
    new-instance v1, Lnet/oauth/OAuthException;

    invoke-direct {v1, v0}, Lnet/oauth/OAuthException;-><init>(Ljava/lang/Throwable;)V

    throw v1
.end method
